package com.giec.autoble;

import android.Manifest;
import android.content.Intent;
import android.os.Bundle;

import com.giec.autoble.service.BleService;
import com.tbruyelle.rxpermissions2.Permission;
import com.tbruyelle.rxpermissions2.RxPermissions;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        requestMutilRxPermission(
                Manifest.permission.ACCESS_COARSE_LOCATION,
                Manifest.permission.ACCESS_FINE_LOCATION);

    }
    protected void requestMutilRxPermission(String... permissions) {
        final RxPermissions rxPermissions = new RxPermissions(this);
        rxPermissions.requestEachCombined(permissions).subscribe(new io.reactivex.functions.Consumer<Permission>() {
            @Override
            public void accept(Permission permission) throws Exception {
                if (permission.granted) {
                    startService(new Intent(MainActivity.this, BleService.class));
                } else if (permission.shouldShowRequestPermissionRationale) {

                } else {

                }
            }
        });


    }

}
